: AMPAR2.mod
: Jose Guzman, sjm.guzman@gmail.com
: Last change: Tue Nov 12 08:48:30 CET 2013

TITLE simplified two-state AMPA/Kainate receptor model

COMMENT
-------------------------------------------------------------------------
A simple kinetic model for an ionotropic ligand-gated receptor model of 
the form:

   [A]*alpha
C  ----------> O 
   <--------- 
      beta

where C is the receptor in close state, A the receptor agonist, O
the receptor in its open state. Alpha is the time constant that describes
the fraction of channel changing from close (C) state to open (O) state. 
Beta is the time constant that describes the fraction of channels moving 
from open (O) to close (C) state. 

The corresponding differential equation that describes the time course of 
the receptor in its open state (dO/dt) upong ligand (A) binding is:

dO(t)/dt = [A]*alpha* ( 1-O(t) ) - beta*O(t)

Once the receptor is open, the corresponding current can be calculated
as follows:

I(t)  = O(t)*gMax*(V-Erev)

where gMax is peak conductance, V is potential and Erev is the
reversal potential for the receptor.

For an example of such type of receptor, check
http://nbviewer.ipython.org/url/pub.ist.ac.at/~jguzman/pub/ipython/2StateReceptorModel.ipynb

If an event arrives at some time t when transmitter is already in the 
synaptic cleft, the time at which transmitter will vanish is moved
to t + dur
-------------------------------------------------------------------------
ENDCOMMENT

NEURON {
    POINT_PROCESS AMPAR2 
    RANGE alpha, beta
    RANGE gMax, Erev
    RANGE nt, dur
    NONSPECIFIC_CURRENT i
}

UNITS {
    (pS) = (picosiemens) 
    (mV) = (millivolt)
    (mM) = (milli/liter)
    (uM) = (micro/liter)
    (nA) = (nanoamp)
}

PARAMETER {
    alpha = 1.1  (/ms mM)    <0.01,1e9>      : binding rate, [nt] dependent 
    beta  = 0.19 (/ms)       <0.01,1e9>      : closing rate
    gMax  = 80 (pS)          <0.0,1e9>       : maximal conductance
    Erev  = 0  (mV)                          : reversal potential
    dur   = 1  (ms)          <0.0,1e9>       : duration of [nt] in the cleft
    
}

ASSIGNED {
    v (mV)      : voltage
    i (nA)      : current as described in BREAKPOINT  
    g (pS)      : conductance as described in BREAKPOINT
    nt (mM)     : agonist concentration in synaptic cleft
    onset (1)   : 1 if neurotransmitter is in the cleft
}

STATE {
    C   : closed state
    O   : open state
}


INITIAL {
    C = 1       : 100% of the fraction is closed
    nt = 0      : no transmitter in the cleft
    onset = 0   : 0 if no [nt] is in the cleft, 1 otherwise
}

BREAKPOINT {
    SOLVE diff METHOD cnexp  : since ODE is linear 
    g = O * gMax
    i = g * (v - Erev) * (1e-6) : current in nA
}

DERIVATIVE diff {
    O' = nt*alpha*(1-O) - beta*O
}

NET_RECEIVE (weight (mM) ){
    if (flag == 0){ : event generated by NetCon 
        if (onset == 0) {  
            onset = 1
            nt = weight
            net_send(dur, 1) : generate event with ID 1 at dur 
        }
        : if other NetCon activates this receptor
        else { : syn has onset, keep it on until t+dur 
            net_move(t+dur)
        }
    }
    else if (flag == 1) { : self event (see net_send), switch it off
        onset = 0
        nt = 0
    }
    
}
